<template>
  <el-form ref="formRef" :model="role" label-width="120px">
    <el-form-item label="角色标示符">
      <el-input v-model="role.roleKey" placeholder="请输入角色标识符"></el-input>
    </el-form-item>
    <el-form-item label="角色名称">
      <el-input v-model="role.roleName" placeholder="请输入角色名称"></el-input>
    </el-form-item>
    <el-form-item label="备注">
      <el-input v-model="role.description" placeholder="请输入备注"  type="textarea"></el-input>
    </el-form-item>
     <el-form-item label="状态">
       <el-switch v-model="role.status"
                  active-text="启用"
                  inactive-text="停用"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                  :active-value=0
                  :inactive-value=2 />
     </el-form-item>
    <el-form-item>
      <el-button @click="add()">添加</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import {addRole} from "@/api/role";
import {ElMessage} from "element-plus";
export default {
  name: "AddRole",
  data() {
    return {
      role:{
        roleKey:'',
        roleName:'',
        description:'',
        status:0
      }
    }
  },
  methods:{
    async add() {
      const t = await addRole(this.role);
      if (t.data.code === 200) {
        ElMessage({
          type:'success',
          message:'添加成功!'
        })
      }

    }
  }
}
</script>

<style scoped>

</style>